from django.db import models

from django.contrib.auth.models import User

class UserProfile(models.Model):
    user = models.ForeignKey(User, unique=True, related_name='profile')
    avatar = models.FileField(upload_to='avatars') #models.ImageField(upload_to='avatars')
    timezone = models.CharField(max_length=50, default='Europe/Paris')
    
class Event(models.Model):
    name = models.CharField(max_length=150)
    start = models.DateField()
    owner = models.ForeignKey(User)
    
class Participant(models.Model):
    user = models.ForeignKey(User) #, on_delete=models.CASCADE)
    event = models.ForeignKey(Event) #, on_delete=models.CASCADE)
    
class Category(models.Model):
    name = models.CharField(max_length=150)
    event = models.ForeignKey(Event) #, on_delete=models.SET_NULL)

class Operation(models.Model):
    amount = models.FloatField()
    date = models.DateField()
    owner = models.ForeignKey(User) #, on_delete=models.SET_NULL)
    note = models.TextField()
    event = models.ForeignKey(Event) #, on_delete=models.CASCADE)
    category = models.ForeignKey(Category)

class Debt(models.Model):
    operation = models.ForeignKey(Operation) #, on_delete=models.CASCADE)
    coef = models.FloatField()
    user = models.ForeignKey(User) #, on_delete=models.SET_NULL)
    amount = models.FloatField()
    done = models.BooleanField()
